package com.cloud.lan.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.cloud.lan.entity.model.dataobject.LanBadgeCfgDO;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Mapper;

/**
 * Created by zhouquan on 2022/5/19.
 */
@Mapper
public interface LanBadgeCfgMapper extends BaseMapper<LanBadgeCfgDO> {

    @Select("select cfg.* from lan_badge_cfg cfg\n" +
            "    left join lan_badge_user_record record on\n" +
            "        cfg.id=record.badge_id\n" +
            "where record.user_id=#{userId}\n" +
            "  and cfg.is_deleted=0\n" +
            "  and record.is_deleted=0\n" +
            "order by record.create_time desc limit 1")
    LanBadgeCfgDO getBadgeByUserId(@Param("userId") long userId);
}
